const http = require("http");
const url = require("url");
var fs = require("fs");
var path = require("path");

var reqUrl = "http://localhost:8081/";

var options = url.parse(reqUrl);
options.method = "POST";

var reqObj = http.request(options, (res) => {
    
})

var userName = process.argv[2];
var pwd = process.argv[3];
var userInfor = {userName: userName, pwd: pwd};
var userStr = JSON.stringify(userInfor);
var filePath = path.join(__dirname, "/data.json");
fs.writeFileSync(filePath, userStr, err => {
    if(err){
        console.log(err);
    }
})
reqObj.write(userStr);//向请求体写入数据
reqObj.end();
